//
//  HomeRoolCell.m
//  Shengzhuli
//
//  Created by FXGuo on 2017/7/13.
//  Copyright © 2017年 kamangkeji. All rights reserved.
//

#import "HomeRoolCell.h"
#import "SDCycleScrollView.h"
#import "BannerModel.h"

@interface HomeRoolCell ()

@property (nonatomic,weak) SDCycleScrollView *roolView;

@end

@implementation HomeRoolCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        SDCycleScrollView *roolView = [SDCycleScrollView cycleScrollViewWithFrame:CGRectMake(8, 0, ScreenW-16, 180) delegate:nil placeholderImage:GetImage(@"default_large_goods_image")];
        roolView.pageControlStyle = SDCycleScrollViewPageContolStyleAnimated;
        roolView.autoScrollTimeInterval = 3.0f;
        roolView.bannerImageViewContentMode = UIViewContentModeScaleAspectFill;
        self.roolView = roolView;
        __WEAK
        roolView.clickItemOperationBlock = ^(NSInteger currentIndex) {
            if (weakSelf.roolBlock) {
                weakSelf.roolBlock(currentIndex);
            }
        };
        [self.contentView addSubview:roolView];
    }
    return self;
}
- (void)setBanners:(NSArray *)banners
{
    _banners = banners;
    NSMutableArray *urls = [NSMutableArray array];
   
        for (BannerModel *model in banners) {
            [urls addObject:[model.avatarUrl componentsSeparatedByString:@"#"].firstObject];
        }
    self.roolView.imageURLStringsGroup = urls;
}
- (void)layoutSubviews
{
    [super layoutSubviews];
    self.roolView.height = self.height;
}

@end
